Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/billing/[[...page]].tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Layout } from "antd";67import { capitalize } from "@cocalc/util/misc";8import { MainPages, MainPagesType } from "components/billing/consts";9import BillingLayout from "components/billing/layout";10import Footer from "components/landing/footer";11import Head from "components/landing/head";12import Header from "components/landing/header";13import { Customize, CustomizeType } from "lib/customize";14import withCustomize from "lib/with-customize";15import Error from "next/error";1617interface Props {18customize: CustomizeType;19pageNotFound: boolean;20page: [MainPagesType | undefined];21}2223export default function Preferences(props: Props) {24const { customize, pageNotFound, page } = props;2526const subpage = page?.[0] != null ? ` - ${capitalize(page[0])}` : "";2728return (29<Customize value={customize}>30<Head title={`Billing${subpage}`} />31<Layout>32<Header />33{pageNotFound ? (34<Error statusCode={404} />35) : (36<BillingLayout page={page} />37)}38<Footer />39</Layout>40</Customize>41);42}4344export async function getServerSideProps(context) {45const { params, res } = context;46const { page = [] } = params;4748// deprecated – https://github.com/sagemathinc/cocalc/issues/573949// see billing/layout.tsx for possible pages50const [main] = page;51switch (main) {52// 307: temp redirect53case "payment-methods":54return res.redirect(307, "./cards");55case "invoices-and-receipts":56return res.redirect(307, "./receipts");57}5859if (main != null && !MainPages.includes(main)) {60return await withCustomize({ context, props: { pageNotFound: true } });61}6263return await withCustomize({64context,65props: { page },66});67}686970